package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.CheckBox;

import com.jp.knowledge.R;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.PayWayModel;

import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/6/27.
 */

public class PayWayAdapter extends RecycleVAdapter<PayWayModel> {

	private int selectIndex = 0;

	public int getSelectIndex() {
		return selectIndex;
	}

	public void setSelectIndex(int selectIndex) {
		this.selectIndex = selectIndex;
	}

	public PayWayAdapter(Context context, @NonNull List<PayWayModel> list) {
		super(context, list);
		this.selectIndex = 0;
	}

	@Override
	public int getLayoutId(int viewType) {
		return R.layout.vip_pay_way_item;
	}

	@Override
	public void onBind(RecycleVHolder holder, int position) {
		PayWayModel payWayModel = getData(position);
		holder.setImageUrl(R.id.pay_way_icon, payWayModel.getIcon());
		holder.setTextView(R.id.pay_way_title, payWayModel.getTitle());
		((CheckBox)holder.get(R.id.pay_way_cb)).setChecked(selectIndex == position);
	}
}
